$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("BaseInfo")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str) => mstform.getItem(str).getValue()

    hideHeakKey()

    useValuesChange(() => {
        getSupplyInfo()
    }, "PhidSupplyEnt")

    useValuesChange(()=>{
        hideHeakKey()
    },"user_sfjcpt")

    // 获取分包商信息
    function getSupplyInfo() {
        const phid = mstform.getItem("PhidSupplyEnt").getValue()
        if (!phid) return
        $NG.execServer("getSupplyInfo", { phid }, (res) => {
            if (res.count == 0) return
            const datas = JSON.parse(res.data)[0].extendObjects
            console.log(`datas`, datas);
            const arr = [
                {
                    key: "user_fbsxcfzr",
                    value: datas.user_fbsxcfzr
                },
                {
                    key: "ub ser_fbsxcfzrsfzh",
                    value: datas.user_fbsxcfzrsfz
                },
                {
                    key: "user_fbsxcfzrlxdh",
                    value: datas.user_fbsxcfzrlxdh
                },
                {
                    key: "user_fbszzdj",
                    value: datas.user_zzdj
                },
                {
                    key: "user_nsrsbh",
                    value: datas.unisocialcredit
                },
                {
                    key: "user_khh",
                    value: datas.taxbank_name
                },
                {
                    key: "user_zh",
                    value: datas.taxaccountno
                },
                {
                    key: "user_dz",
                    value: datas.taxaddress
                },
                {
                    key: "user_hh",
                    value: datas.taxbank_no
                },
                {
                    key: "user_lxr",
                    value: datas.cname
                },
                {
                    key: "user_dh",
                    value: datas.officetel
                },
                {
                    key: "user_sj",
                    value: datas.handset
                },

            ]
            setHeadValues(arr)
        })
    }

    // 隐藏标头字段
    function hideHeakKey() {
        const user_sfjcpt = mstform.getItem("user_sfjcpt").getValue()
        let hidden = true
        if (user_sfjcpt == '01') {
            hidden = false
        }
        mstform.getItem("user_jcptcgbh").setProps({
            hidden
        })
    }
    // 表头批量赋值
    function setHeadValues(arr) {
        arr.forEach(item => {
            console.log(`执行更新`, item);
            mstform.getItem(item.key)?.setValue(item.value)
        })
    }
})